package cn.diancan.model;
 
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;

import cn.diancan.util.DateUtil;

/**
 * 货品表
 * @author  
 *
 */
@Entity
@Table(name="Product",uniqueConstraints = {@UniqueConstraint(columnNames={"barcode"})}) 
public class Product  {
	
	private Long id;//主键
	private Long goodsId;//产品ID
	
	private String barCode; //条码
	
	//空的时候读取 Goods 的数据
	private Double tagPrice;    //吊牌价(不使用)
	private Double retailPrice;  //销售价格(不使用)
	
	private Long colorSpecificationValueId; //颜色规格
	private Long sizeSpecificationValueId;  //尺码规格
	
	private Integer stockCount;  //库存数
	
	private String createTime;

	private Integer indexNo;
	private Integer isEnable; //1：上架 0：下架
	private Integer isDelete;   //删除标识 1标识删除
	
	//@BelongsTo(foreignKey="goodsId") 
	//private FoodInfo doods;
	//获取规格列表
	//private List<Long> specificationIdList;
	private List<ProductSpecificationValues> sroductSpecificationValuesList; //规格列表
	
	
	private long lastUpdateTimeStamp;//真实数据需要
	private Integer version;
	
	
        public long getLastUpdateTimeStamp() {
    		return lastUpdateTimeStamp;
        }
        public void setLastUpdateTimeStamp(long lastUpdateTimeStamp) {
    		this.lastUpdateTimeStamp = lastUpdateTimeStamp;
        }
        @Version
        @Column(name = "OPTLOCK", columnDefinition = "int(11) DEFAULT 0")
        public Integer getVersion() {
    		return version;
        }
        public void setVersion(Integer version) {
    		this.version = version;
        }

	@Id
	@GeneratedValue
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(Long goodsId) {
		this.goodsId = goodsId;
	}

	/*public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}*/
	

	public Integer getStockCount() {
		return stockCount;
	}

	public Double getTagPrice() {
	    return tagPrice;
	}

	public void setTagPrice(Double tagPrice) {
	    this.tagPrice = tagPrice;
	}

	public Double getRetailPrice() {
	    return retailPrice;
	}

	public void setRetailPrice(Double retailPrice) {
	    this.retailPrice = retailPrice;
	}

	public void setStockCount(Integer stockCount) {
		this.stockCount = stockCount;
	}

	
	
	@Column(columnDefinition="VARCHAR(32)")
	public String getBarCode() {
	    return barCode;
	}

	public void setBarCode(String barCode) {
	    this.barCode = barCode;
	}

	@Column(name="createTime",columnDefinition="DATETIME")
	public String getCreateTime() {
	    return DateUtil.getMysqlDateTime(createTime);
	}

	public void setCreateTime(String createTime) {
	    this.createTime = createTime;
	}

	public Integer getIsEnable() {
	    return isEnable;
	}

	public void setIsEnable(Integer isEnable) {
	    this.isEnable = isEnable;
	}

	public Integer getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(Integer isDelete) {
		this.isDelete = isDelete;
	}
	
	/*@ManyToOne(cascade=CascadeType.ALL,fetch = FetchType.LAZY)
	@JoinColumn(name="goodsId")
	public FoodInfo getDoods() {
		return doods;
	}
	 
	public void setDoods(FoodInfo doods) {
		this.doods = doods;
	}*/
	
	
	//@OneToMany(mappedBy="product",cascade=CascadeType.ALL,fetch = FetchType.LAZY) 
	@OneToMany(mappedBy="productId",cascade=CascadeType.ALL,fetch = FetchType.LAZY) 
	public List<ProductSpecificationValues> getSroductSpecificationValuesList() {
		return sroductSpecificationValuesList;
	}
	
	public void setSroductSpecificationValuesList(
			List<ProductSpecificationValues> sroductSpecificationValuesList) {
		this.sroductSpecificationValuesList = sroductSpecificationValuesList;
	}

	public Long getColorSpecificationValueId() {
	    return colorSpecificationValueId;
	}

	public void setColorSpecificationValueId(Long colorSpecificationValueId) {
	    this.colorSpecificationValueId = colorSpecificationValueId;
	}

	public Long getSizeSpecificationValueId() {
	    return sizeSpecificationValueId;
	}

	public void setSizeSpecificationValueId(Long sizeSpecificationValueId) {
	    this.sizeSpecificationValueId = sizeSpecificationValueId;
	}

	public Integer getIndexNo() {
		return indexNo;
	}

	public void setIndexNo(Integer indexNo) {
		this.indexNo = indexNo;
	}
}
